package com.salt.modules.sys.web;

import com.salt.common.json.AjaxJson;
import com.salt.core.log.annotation.OperationRecord;
import com.salt.core.web.BaseController;
import com.salt.modules.sys.entity.BackgroundSysUser;
import com.salt.modules.sys.service.BackgroundSysUserService;
import com.salt.modules.sys.utils.UserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * (BackgroundSysUser)表控制层
 *
 * @author makejava
 */
@Api(tags = "设置背景图片")
@RestController
@CrossOrigin
@RequestMapping("/sys/background/user")
public class BackgroundSysUserController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private BackgroundSysUserService backgroundSysUserService;



    /**
     * @Author yan
     * @return
     */
    @ApiOperation(value = "查询背景图片")
    @GetMapping("findImage")
    public AjaxJson findImage() {

        return AjaxJson.success().put("data", backgroundSysUserService.queryById(UserUtils.getUser().getId()));
    }





    /**
     * 修改背景图片
     *
     */
    @ApiOperation(value = "通过主键查询单条数据")
    @PostMapping("update")
    @OperationRecord(service = "系统服务", module = "背景图片", operation = "修改", description = "修改/背景图片")
    public AjaxJson selectOne(BackgroundSysUser backgroundSysUser) {
        backgroundSysUser.setId(UserUtils.getUser().getId());
        this.backgroundSysUserService.updateBackgroundImage(backgroundSysUser);
        return AjaxJson.success();
    }
}